import 'dart:convert';
// import 'package:ichinesereader/exam/dto/assessment.response.dart';
import 'package:ichinesereader/models/knowledgeword/knowledgeWord.dart';

import '../assessment/questionRecordSection.dart';

KnowledgeDetailsResult knowledgeItemsResultFromJson(String str) =>
    KnowledgeDetailsResult.fromJson(json.decode(str));
String knowledgeItemsResultToJson(KnowledgeDetailsResult data) =>
    json.encode(data.toJson());

class KnowledgeDetailsResult {
  KnowledgeDetailsResult({
    this.status,
    this.message,
    this.result,
  });

  int? status;
  String? message;
  Result? result;

  factory KnowledgeDetailsResult.fromJson(Map<String, dynamic> json) =>
      KnowledgeDetailsResult(
        status: json["status"],
        message: json["message"],
        result: json["result"] != null ? Result.fromJson(json["result"]) : null,
      );

  Map<String, dynamic> toJson() => {
        "status": status,
        "message": message,
        "result": result != null ? result?.toJson() : null,
      };
}

class Result {
  Result({
    this.grammar,
    this.phrase,
    this.syllable,
    this.word,
  });

  List<QuestionRecordSection>? grammar;
  List<KnowledgeWord>? phrase;
  List<KnowledgeSyllable>? syllable;
  List<KnowledgeHandwritingWord>? word;

  factory Result.fromJson(Map<String, dynamic> json) => Result(
        grammar: json["grammar"] != null
            ? List<QuestionRecordSection>.from(
                json["grammar"].map((x) => QuestionRecordSection.fromJson(x)))
            : null,
        phrase: json["phrase"] != null
            ? List<KnowledgeWord>.from(
                json["phrase"].map((x) => KnowledgeWord.fromJson(x)))
            : null,
        syllable: json["syllable"] != null
            ? List<KnowledgeSyllable>.from(
                json["syllable"].map((x) => KnowledgeSyllable.fromJson(x)))
            : null,
        word: json["word"] != null
            ? List<KnowledgeHandwritingWord>.from(
                json["word"].map((x) => KnowledgeHandwritingWord.fromJson(x)))
            : null,
      );

  Map<String, dynamic> toJson() => {
        "grammar": grammar != null
            ? List<dynamic>.from(grammar!.map((x) => x.toJson()))
            : null,
        "phrase": phrase != null
            ? List<dynamic>.from(phrase!.map((x) => x.toJson()))
            : null,
        "syllable": syllable != null
            ? List<dynamic>.from(syllable!.map((x) => x.toJson()))
            : null,
        "word": word != null
            ? List<dynamic>.from(word!.map((x) => x.toJson()))
            : null,
      };
}

// class KnowledgeGrammar {
//   KnowledgeGrammar({
//     this.subCategory,
//     this.level,
//     this.commitTime,
//     this.kind,
//     this.questions,
//     this.id,
//     this.text,
//     this.type,
//     this.category,
//     this.sample,
//   });

//   String? subCategory;
//   int? level;
//   int? commitTime;
//   List<GrammarQuestion>? questions;
//   String? kind;
//   String? id;
//   String? text;
//   String? type;
//   String? category;
//   String? sample;

//   factory KnowledgeGrammar.fromJson(Map<String, dynamic> json) =>
//       KnowledgeGrammar(
//         subCategory: json["subCategory"],
//         level: json["level"],
//         commitTime: json["commitTime"],
//         questions: json["questions"] != null
//             ? List<GrammarQuestion>.from(
//                 json["questions"].map((x) => GrammarQuestion.fromJson(x)))
//             : null,
//         kind: json["kind"],
//         id: json["id"],
//         text: json["text"],
//         type: json["type"],
//         category: json["category"],
//         sample: json["sample"],
//       );

//   Map<String, dynamic> toJson() => {
//         "subCategory": subCategory,
//         "level": level,
//         "commitTime": commitTime,
//         "kind": kind,
//         "id": id,
//         "questions": questions != null
//             ? List<dynamic>.from(questions!.map((x) => x.toJson()))
//             : null,
//         "text": text,
//         "type": type,
//         "category": category,
//         "sample": sample,
//       };
// }

// class GrammarQuestion {
//   GrammarQuestion({
//     this.question,
//     this.id,
//     this.content,
//   });

//   List<QuestionItem>? question;
//   String? id;
//   QuestionContent? content;

//   factory GrammarQuestion.fromJson(Map<String, dynamic> json) =>
//       GrammarQuestion(
//         question: List<QuestionItem>.from(
//             json["question"].map((x) => QuestionItem.fromJson(x))),
//         id: json["id"],
//         content: QuestionContent.fromJson(json["content"]),
//       );

//   Map<String, dynamic> toJson() => {
//         "question": question != null
//             ? List<dynamic>.from(question!.map((x) => x.toJson()))
//             : null,
//         "id": id,
//         "content": content != null ? content?.toJson() : null,
//       };
// }

class KnowledgeSyllable {
  KnowledgeSyllable({
    this.syllable,
    this.level,
    this.id,
  });

  String? syllable;
  int? level;
  String? id;

  factory KnowledgeSyllable.fromJson(Map<String, dynamic> json) =>
      KnowledgeSyllable(
        syllable: json["syllable"],
        level: json["level"],
        id: json["id"],
      );

  Map<String, dynamic> toJson() => {
        "syllable": syllable,
        "level": level,
        "id": id,
      };
}

class KnowledgeHandwritingWord {
  KnowledgeHandwritingWord({
    this.handWriting,
    this.list,
  });

  String? handWriting;
  List<KnowledgeWord>? list;

  factory KnowledgeHandwritingWord.fromJson(Map<String, dynamic> json) =>
      KnowledgeHandwritingWord(
        handWriting: json["handWriting"],
        list: json["list"] != null
            ? List<KnowledgeWord>.from(
                json["list"].map((x) => KnowledgeWord.fromJson(x)))
            : null,
      );

  Map<String, dynamic> toJson() => {
        "handWriting": handWriting,
        "list": list != null
            ? List<dynamic>.from(list!.map((x) => x.toJson()))
            : null,
      };
}
